package com.wao.editor.client;

import com.wao.editor.domain.FileKey;
import com.wao.editor.domain.FileListing;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@AuthorizedFeignClient(name = "file", fallback = FileClientHystrix.class, configuration = OAuth2InterceptedFeignConfiguration.class)
public interface FileClient {

    @RequestMapping(value = "/api/files", method = RequestMethod.POST, produces = MediaType.ALL_VALUE,
            consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public FileKey upload(@RequestParam(name = "path") String path,
                          @RequestPart(name = "file") MultipartFile file);

    @RequestMapping(value = "/api/files", method = RequestMethod.GET)
    public FileListing getFileList(@RequestParam(name = "prefix") String prefix,
                                   @RequestParam(name = "marker") String marker,
                                   @RequestParam(name = "limit") Integer limit,
                                   @RequestParam(name = "delimiter") String delimiter);

    @RequestMapping(value = "/api/domains", method = RequestMethod.GET)
    public List<String> getDomains();
}
